﻿package mortal.game.view.combinedServer.combinedSerDayRe1000
{
    import Message.Game.*;
    import com.mui.controls.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class CombinedSerDayRe1000Cell extends GCellRenderer
    {
        protected var ui_0:GImageBitmap;
        protected var _item:BaseItem;
        protected var _getBtn:GLoadingButton;
        protected var _hasGet:GImageBitmap;
        protected var _title1:GImageBitmap;
        protected var _timeDes:GImageBitmap;
        protected var _timeTxt:BitmapNumberText;
        private var _info:Object;

        public function CombinedSerDayRe1000Cell()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.ui_0 = UIFactory.gImageBitmap(ImagesConst.CombinedSerRe1000CellBg, 0, 0, this);
            this._item = UIFactory.getUICompoment(BaseItem);
            this._item.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            UIFactory.setObjAttri(this._item, 30, 62, -1, -1, this);
            this._getBtn = UIFactory.gLoadingButton(ImagesConst.LineOffCopyCellBtn_upSkin, 39, 146, 53, 22, this);
            this._getBtn.label = "领取";
            this._hasGet = UIFactory.gImageBitmap(ImagesConst.HasGetRewardFlag, 33, 113, this);
            this._title1 = UIFactory.gImageBitmap(ImagesConst.CombinedSerRe1000Cell1Title, 29, 7, this);
            this._timeDes = UIFactory.gImageBitmap(ImagesConst.CombinedSerRe1000Cell1TimeDes, 31, 31, this);
            this._timeTxt = UIFactory.bitmapNumberText(65, 32, "CombinedSerRe1000Num.png", 18, 22, -6, this, 9, 1);
            this._timeTxt.text = "20";
            var _loc_1:* = new ItemData(4);
            _loc_1.itemAmount = 500;
            this._item.itemData = _loc_1;
            this._hasGet.visible = false;
            this._getBtn.configEventListener(MouseEvent.CLICK, this.onGetRw);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.setBtn(this._getBtn, false);
            this.ui_0 = null;
            this._item = null;
            this._getBtn = null;
            this._hasGet = null;
            this._title1 = null;
            this._timeDes = null;
            this._timeTxt = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._info = param1;
            if (this._info == null)
            {
                return;
            }
            var _loc_2:* = this._info.index;
            this._timeTxt.text = "" + (_loc_2 + 1);
            var _loc_3:* = Cache.instance.combinedSer.recharge1000Info;
            if (_loc_3 == null)
            {
                return;
            }
            var _loc_4:* = _loc_3.recharge / CombinedSerDayRe1000Util.oneNum;
            this._hasGet.visible = false;
            this._getBtn.label = "领取";
            if (_loc_4 >= (_loc_2 + 1))
            {
                if ((_loc_2 + 1) == (_loc_3.getTimes + 1))
                {
                    this.setBtn(this._getBtn, true);
                }
                else if ((_loc_2 + 1) > _loc_3.getTimes)
                {
                    this.setBtn(this._getBtn, true);
                }
                else
                {
                    this._hasGet.visible = true;
                    this._getBtn.label = "已领取";
                    this.setBtn(this._getBtn, false);
                }
            }
            else
            {
                this.setBtn(this._getBtn, false);
            }
            this._getBtn.drawNow();
            return;
        }// end function

        private function setBtn(param1:GLoadingButton, param2:Boolean) : void
        {
            if (param2)
            {
                param1.enabled = true;
                param1.filters = null;
                EffectManager.glowFilterReg(param1);
            }
            else
            {
                param1.enabled = false;
                EffectManager.glowFilterUnReg(param1);
                param1.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

        private function onGetRw(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(ThanksGivingEvent.CombinedSerRe1000GetRw));
            this.flyIcon();
            return;
        }// end function

        public function flyIcon() : void
        {
            if (this._item == null || this._item.bitmapdata == null)
            {
                return;
            }
            var _loc_1:* = this._item.localToGlobal(GameConst.yellowPoint);
            FlyToNavbarTool.flyBitmapOriginalToPack(this._item.bitmapdata, _loc_1);
            return;
        }// end function

    }
}
